package com.cskaoyan.dbutils;

import com.cskaoyan.datasource.opensource.DruidUtils;
import com.cskaoyan.jdbc.util.JDBCUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * 创建日期: 2022/06/05 17:23
 *
 * @author ciggar
 */
public class DBUtilsDemo1 {


    public static void main2(String[] args) throws SQLException {

        // 获取queryRunner
        QueryRunner queryRunner = new QueryRunner();

//        QueryRunner queryRunner1 = new QueryRunner(DruidUtils.getDataSource());

        Connection connection = JDBCUtils.getConnection();

        int effectedRows = queryRunner.update(connection,"update cskaoyan set money = ? where id in (?,?)",1,1001,1002);

        System.out.println(effectedRows);

        connection.close();

    }


    public static void main(String[] args) throws SQLException {

        // 获取queryRunner,传入数据库连接池
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());


        int effectedRows = queryRunner.update("update cskaoyan set money = ? where id in (?,?)",100,1003,1004);

        System.out.println(effectedRows);


    }
}
